﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DBAccess
{
    internal class Execute : iExecute
    {
        public Execute()
        { }

        public void ExecuteNonQuery(string sql)
        {      
            SqlConnection conn =  BuildIConnect.Build().OpenConnection();
            SqlCommand command = new SqlCommand(sql, conn);
            command.ExecuteNonQuery();
            BuildIConnect.Build().CloseConnection(conn);
        }

        public DataTable ExecuteQuery(string sql)
        {
            SqlConnection conn = BuildIConnect.Build().OpenConnection();
            SqlCommand command = new SqlCommand(sql, conn);
            SqlDataReader reader = command.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            BuildIConnect.Build().CloseConnection(conn);
            return dt;
        }
    }
}
